import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '任务类型',
    align: 'center',
    dataIndex: 'taskType_dictText',
    // customRender: ({ text }) => {
    //   return render.renderDict(text, 'task_type');
    // },
  },
  {
    title: '设备任务',
    align: 'center',
    dataIndex: 'business_dictText',
    // customRender: ({ text }) => {
    //   return render.renderDict(text, 'task_business');
    // },
  },

  {
    title: '油站名称',
    align: 'center',
    dataIndex: 'station',
  },
  {
    title: '加油站',
    align: 'center',
    dataIndex: 'station',
  },

  {
    title: '状态',
    align: 'center',
    dataIndex: 'status_dictText',
  },
  {
    title: '领用人员',
    align: 'center',
    dataIndex: 'statusUpdateBy_dictText',
  },
  {
    title: '操作员',
    align: 'center',
    dataIndex: 'createBy_dictText',
  },
  {
    title: '添加日期',
    align: 'center',
    dataIndex: 'createTime',
  },
  {
    title: '备注',
    align: 'center',
    dataIndex: 'note',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '任务类型',
    field: 'taskType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'task_type',
      placeholder: '任务类型',
      stringToNumber: true,
    },
  },
  {
    label: '任务状态',
    field: 'collectingBy_dictText',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'task_status',
      placeholder: '请选择任务状态',
      stringToNumber: true,
    },
  },
  {
    field: 'statusUpdateBy',
    component: 'JSelectUser',
    label: '领用人员',
    componentProps: {
      maxSelectCount: 1, // 最大选择数
      labelKey: 'realname',
      rowKey: 'username',
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '任务类型',
    field: 'taskType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'task_type',
      placeholder: '请选择类型',
      stringToNumber: true,
    },
    rules: [{ required: true, trigger: 'blur' }],
  },
  {
    label: '设备任务',
    field: 'business',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'task_business',
      placeholder: '请选择类型',
      stringToNumber: true,
    },
    rules: [{ required: true, trigger: 'blur' }],
  },
  {
    rules: [{ required: true, trigger: 'blur' }],
    field: 'deviceId',
    component: 'JPopup',
    label: '设备ID',
    helpMessage: ['component模式'],
    colProps: {
      span: 24,
    },
    componentProps: ({ formActionType }) => {
      let { setFieldsValue } = formActionType;
      return {
        setFieldsValue: setFieldsValue,
        placeholder: '请选择',
        code: 'seal_device_task',
        fieldConfig: [{ source: 'sys_org_code', target: 'deviceId' }],
        //是否为多选
        multi: false,
      };
    },
  },
  {
    label: '备注',
    field: 'note',
    component: 'Input',
  },
  {
    component: 'JSelectUser',
    field: 'statusUpdateBy',
    label: '领取人员',
    helpMessage: ['component模式'],

    componentProps: {
      maxSelectCount: 1, // 最大选择数
      labelKey: 'realname',
      rowKey: 'username',
    },
    rules: [{ required: true, trigger: 'blur' }],
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
// 高级查询数据
export const superQuerySchema = {
  taskType: { title: '任务类型', order: 1, view: 'text', type: 'string' },
  deviceId: { title: '设备ID', order: 2, view: 'text', type: 'string' },
  note: { title: '备注', order: 3, view: 'text', type: 'string' },
  status: { title: '任务状态', order: 4, view: 'number', type: 'number' },
  username: { title: '用户名称', order: 5, view: 'text', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
